Skip to content

Conversation

@whqtker
Copy link
Member

@whqtker whqtker commented Feb 1, 2026

관련 이슈

작업 내용

채팅 관련 QA를 진행하는데, STOMP 프레임이 로깅되지 않아 동작을 제대로 확인하기 어려웠습니다.

이에 STOMP 프레임을 로깅하는 인터셉터를 작성했습니다.
dev 프로파일인 경우에만 동작하도록 구현했습니다. prod 프로파일에서도 로깅하면 사용자 채팅 등이 로깅될 수 있기에, 보안 상의 문제가 있을 거라도 판단했습니다.
선택적으로 인터셉터를 스프링 컨테이너에 등록하기에, Optional 로 주입했고 ifPresent 로 처리하게끔 구현했습니다.

특이 사항

리뷰 요구사항 (선택)

@coderabbitai
Copy link

coderabbitai bot commented Feb 1, 2026

Walkthrough

  1. 새 컴포넌트 추가: WebSocketLoggingInterceptor가 Dev 프로필에서 활성화되는 Spring 컴포넌트로 추가되었습니다.
  2. 로깅 동작: 이 인터셉터는 ChannelInterceptor를 구현하고 preSend에서 STOMP 명령(CONNECT, SUBSCRIBE, SEND, DISCONNECT)을 검사해 사용자 ID와 함께 로깅합니다.
  3. 구성 변경: StompWebSocketConfigOptional<WebSocketLoggingInterceptor> 필드가 추가되었습니다.
  4. 채널 설정 변경: configureClientInboundChannel에서 인터셉터가 존재하면 먼저 등록하도록 조건부 로직이 추가되었습니다.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • wibaek
  • lsy1307
  • Gyuhyeok99
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경사항의 핵심을 명확하게 설명하고 있으며, WebSocket 로깅 인터셉터 추가라는 주요 변경사항을 정확히 반영하고 있습니다.
Description check ✅ Passed PR 설명이 템플릿 구조를 따르고 있으며, 관련 이슈, 작업 내용, 보안 고려사항 등이 충분히 기재되어 있습니다.
Linked Issues check ✅ Passed PR이 이슈 #634를 해결하고 있으며, STOMP 프레임 로깅 인터셉터를 구현했고 dev 프로파일 제한, Optional 주입 등 요구사항을 충족합니다.
Out of Scope Changes check ✅ Passed 모든 변경사항이 WebSocket 로깅 인터셉터 기능 범위 내에 있으며, 추가된 두 파일(WebSocketLoggingInterceptor, StompWebSocketConfig 수정)이 모두 관련 이슈의 목표를 직접 지원합니다.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@src/main/java/com/example/solidconnection/chat/config/WebSocketLoggingInterceptor.java`:
- Around line 45-52: In extractUserId, avoid potential NPE/ClassCastException by
fetching tokenAuth.getPrincipal() into a local variable, check that it is
non-null and an instance of SiteUserDetails before casting, and only then call
getSiteUser().getId(); if the principal is null or not a SiteUserDetails, return
null. Update the method (referencing extractUserId,
TokenAuthentication.getPrincipal, and SiteUserDetails) to perform these safe
null/instance checks and short-circuit to null for invalid cases.

Copy link
Contributor

@sukangpunch sukangpunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!! 궁금한 점 리뷰 달았습니다

public void configureClientInboundChannel(ChannelRegistration registration) {
InboundProperties inboundProperties = stompProperties.threadPool().inbound();
registration.interceptors(stompHandler).taskExecutor().corePoolSize(inboundProperties.corePoolSize()).maxPoolSize(inboundProperties.maxPoolSize()).queueCapacity(inboundProperties.queueCapacity());
webSocketLoggingInterceptor.ifPresent(registration::interceptors);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

혹시 인터셉터 등록 순서 문제는 발생하지 않나요?
StompHandler 보다 이전에 로깅 인터셉터가 등록 되었을 때, User Principal 을 잘 가져올 수 있는지 궁금합니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

둘 다 Principal을 읽기만 하기에 문제없을 것 같습니다 !

@whqtker whqtker merged commit 2fef77c into solid-connection:develop Feb 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: WebSocket 로깅 인터셉터 작성

2 participants